#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
	int n = 100;
	int s;
	pid_t pid = fork();
	if (-1 == pid){
		perror("fork()");
		return 0;
	}
	if (0 == pid){
		printf ("child: pid = %d ppid  = %d\n",getpid(),getppid());
		getchar();
		printf ("n = %d\n",n);
		exit (0);
	}else{
		wait (&s);
		if (WIFEXITED(s)){
			printf("child exit code: %d\n",WIFEXITED(s));
		}
		if (WIFSIGNALED(s)){
			printf ("signal num: %d\n",WIFSIGNALED(s));
		}
		printf ("parent: pid = %d ppid  = %d n = %d\n",getpid(),getppid(),n);
	}
	return 0;
}
